<template>
  <el-dialog :visible.sync="isShow" width="1280px" :title="componentModel.title">
    <el-row>
      <el-col :span="24">
        <!-- 区域二 -->
      <div style="display: flex;flex-direction: row;flex-wrap: wrap;">
        <div v-for="(node, index) in nodeList" :key="index" style="margin-right: 30px;margin-bottom: 30px;position: relative;">
          <div style="border: 1px solid #ddd;">
            <placeCenter ref="placeCenter" :flag="2" :node="node" :index="index" @replaceTemplate="replaceTemplate"></placeCenter>
          </div>
        </div>
      </div>
      </el-col>
    </el-row>
  </el-dialog>
</template>

<script>
import placeCenter from '../../../placeCenter'
export default {
  components: { placeCenter },
  data() {
    return {
      page: 1,
      size: 100,
      isShow: false,
      sizeValue: '',
      totalSize: 0,
      nodeList: [],
      searchParams: {},
      filter: {},
      itemFilter: '',
      radioValue: '1',
      multipleSelection: [],
      componentModel: '',
      nodeId: '',
      node: {}
    }
  },
  created() {
    
  },
  methods: {
    show(){
      this.isShow = true
      this.getDataList()
    },
    close(){
      this.isShow = false
    },
    replaceTemplate(e){
      this.close()
      this.$emit("replaceTemplate", e)
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSearch() {
      this.getDataList()
    },
    // 获取列表数据
    getDataList() {
      this.searchParams.page = this.page
      this.searchParams.size = this.size
      this.searchParams.component = this.componentModel.id
      this.searchParams.isTemplate = 1
      this.request_get('interface/node/', this.searchParams).then(res => {
        if (res.data.code == 10000) {
          this.totalSize = res.data.data.total_count
          this.nodeList = res.data.data.list
        }
      });
    },
    confirm(){
      var query = {}
      if(this.radioValue == '1'){
        query.dataType = '1'
        query.url = 'system/articleForP/getArticlesByIds/'
        query.routeName = 'articleDetail'
        query.modal = 'push'
        query.ids = this.multipleSelection.map(item => item.id)
      }else if(this.radioValue == '2'){
        if(!this.itemFilter){
          this.$message.error('请选择筛选条件');
          return
        }
        query.dataType = '2'
        query.url = 'system/articleForP/'
        query.routeName = 'articleDetail'
        query.modal = 'push'
        query = Object.assign(query, this.tools.paramsToObj(this.itemFilter))
      }
      this.$emit('handleSelect', JSON.stringify(query))
      this.isShow = false
    },
  },
}
</script>
<style scoped lang='scss'>
  .mouseenter{
    background-color: #333;
  }
</style>
